home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 29 / CDT29.iso / e-Mail / WorldClient Pro 2.2.3 / wcsetup.exe / WEBHELP.ZIP / hhapplet / PopupMenu.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-10-21  |  2.4 KB  |  86 lines

  1. package hhapplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.Button;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Dimension;
  8. import java.awt.Event;
  9. import java.awt.Frame;
  10. import java.awt.GridLayout;
  11. import java.awt.Point;
  12. import java.awt.Rectangle;
  13. import java.awt.Toolkit;
  14. import java.awt.Window;
  15. import java.net.MalformedURLException;
  16. import java.util.Vector;
  17.  
  18. public class PopupMenu extends Window {
  19.    private Applet m_applet;
  20.    private Vector m_vEntries;
  21.    private boolean m_bIsIE3 = false;
  22.    private Point m_pntPosition;
  23.  
  24.    public PopupMenu(Applet var1, Vector var2) {
  25.       super((Frame)null);
  26.       this.m_applet = var1;
  27.       this.m_vEntries = var2;
  28.       ((Container)this).setLayout(new GridLayout(var2.size(), 1));
  29.  
  30.       for(int var3 = 0; var3 < var2.size(); ++var3) {
  31.          ((Container)this).add(new Button(((IndexSecondaryEntry)this.m_vEntries.elementAt(var3)).name));
  32.       }
  33.  
  34.       ((Window)this).pack();
  35.       Rectangle var7 = ((Component)this).bounds();
  36.       if (var7.width < 150) {
  37.          var7.width = 150;
  38.          ((Component)this).resize(var7.width, var7.height);
  39.       }
  40.  
  41.       Dimension var4 = Toolkit.getDefaultToolkit().getScreenSize();
  42.       int var5 = var4.width / 2 - var7.width / 2;
  43.       int var6 = var4.height / 2 - var7.height / 2;
  44.       this.m_pntPosition = new Point(var5, var6);
  45.       ((Component)this).move(var5, var6);
  46.    }
  47.  
  48.    public void show() {
  49.       if (this.m_bIsIE3) {
  50.          Dimension var1 = ((Component)this).size();
  51.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  52.          super.show();
  53.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  54.       } else {
  55.          super.show();
  56.       }
  57.    }
  58.  
  59.    public boolean action(Event var1, Object var2) {
  60.       String var3 = var2.toString();
  61.  
  62.       for(int var4 = 0; var4 < this.m_vEntries.size(); ++var4) {
  63.          if (var3 == ((IndexSecondaryEntry)this.m_vEntries.elementAt(var4)).name) {
  64.             try {
  65.                IndexSecondaryEntry var5 = (IndexSecondaryEntry)this.m_vEntries.elementAt(var4);
  66.                String var6 = var5.frame != null ? var5.frame : "_self";
  67.                this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var5.local, var5.url), var6);
  68.             } catch (MalformedURLException var7) {
  69.             }
  70.  
  71.             ((Window)this).dispose();
  72.          }
  73.       }
  74.  
  75.       return true;
  76.    }
  77.  
  78.    public boolean handleEvent(Event var1) {
  79.       if (var1.id == 201) {
  80.          ((Window)this).dispose();
  81.       }
  82.  
  83.       return super.handleEvent(var1);
  84.    }
  85. }
  86.